package com.sunrise.dispatcher.addressbook.data;

import java.io.Serializable;

import com.sunrise.dispatcher.model.Person;
import com.vaadin.data.util.BeanItemContainer;

@SuppressWarnings("serial")
public class PersonContainer extends BeanItemContainer<Person> implements
		Serializable {

	/**
	 * Natural property order for Person bean. Used in tables and forms.
	 */
	public static final Object[] NATURAL_COL_ORDER = new Object[] {
			"firstName", "lastName", "email", "phoneNumber", "streetAddress",
			"postalCode", "city" };

	/**
	 * "Human readable" captions for properties in same order as in
	 * NATURAL_COL_ORDER.
	 */
	public static final String[] COL_HEADERS_ENGLISH = new String[] {
			"First name", "Last name", "Email", "Phone number",
			"Street Address", "Postal Code", "City" };

	public PersonContainer() throws InstantiationException,
			IllegalAccessException {
		super(Person.class);
	}

	public static PersonContainer createWithTestData() {
		PersonContainer c = null;
		try {
			c = new PersonContainer();
			c.addAll(Person.findAllPeople());
		} catch (InstantiationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return c;
	}

}
